using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;

namespace SocketTool.Views.DialogWindows
{
    public partial class ConfirmMessageDialogWindow : Window
    { 
        private string _tips = string.Empty;
        public ConfirmMessageDialogWindow()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
        }

        public ConfirmMessageDialogWindow(string tips)
        {
            this._tips = tips;
            InitializeComponent();
            this.Opened += (s, e) =>
            {
                txt_Tips = this.FindControl<global::Avalonia.Controls.TextBlock>("txt_Tips");
                txt_Tips.Text = this._tips;
            };
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }

        public bool? DialogResult { get; private set; }
        
        private void Cancel_OnClick(object? sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        private void Confirm_OnClick(object? sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }
    }
}